<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	>
<h:head>
	<title>Fiap Airport Web</title>
</h:head>
<h:body>
	<ui:include src="/cliente/menu.xhtml"/>
	<rich:panel header="Lista de Trecho">
	<h:form>
		<div>
			<span>Voo:</span>
			<h:selectOneMenu value="#{filtroTrechoBean.filtroTrecho.voo.numero}">
				<f:selectItem itemValue="" itemLabel="Selecione" />               
			    <f:selectItems value="#{filtroTrechoBean.voos}" />
			</h:selectOneMenu>
		</div>
		<div>
			<span>Data de Início:</span>
			<rich:calendar value="#{filtroTrechoBean.filtroTrecho.dataInicio}">  
			   <f:convertDateTime pattern="dd/MM/yyyy"/>  
			</rich:calendar>
		</div>
		<div>
			<span>Data de Fim:</span>
			<rich:calendar value="#{filtroTrechoBean.filtroTrecho.dataFim}">  
			   <f:convertDateTime pattern="dd/MM/yyyy"/>  
			</rich:calendar>
		</div>
    	<p>
			<h:commandButton action="#{filtroTrechoBean.filtrarTrechos()}" value="Filtrar" />
			<h:commandButton action="#{trechoBean.novoTrecho}" value="Novo" />
		</p>
		
		<h:dataTable id="trechosTable" value="#{filtroTrechoBean.trechos}" var="trecho">
			<f:facet name="header">
				<h:outputText value="Lista de Trechos" />
			</f:facet>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Código" />
				</f:facet>
				<h:commandLink action="#{trechoBean.recuperarVoo(trecho.id)}" value="#{trecho.id}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Numero do Voo" />
				</f:facet>
				<h:outputText value="#{trecho.voo.numero}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Data do Trecho" />
				</f:facet>
				<h:outputText value="#{trecho.data}" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Ação" />
				</f:facet>
				<h:commandLink action="#{filtroTrechoBean.excluirTrecho(trecho.id)}" value="Excluir" />
			</h:column>
		</h:dataTable>

	</h:form>
	</rich:panel>
</h:body>
</html>
